package cn.pn.project.mapper.base;

import cn.pn.project.pojo.base.Img;
import org.apache.ibatis.annotations.*;

@Mapper
public interface ImgMapper {
    /**
     * 添加图片
     * @return 0 1
     * @throws Exception
     */
    @Insert({"INSERT INTO pn_base.`img` VALUES(NULL,#{imgURL},4,#{releId},NULL,NULL,NULL,NULL); "})
    @Options(useGeneratedKeys = true, keyProperty = "imgId", keyColumn = "imgId")
    Integer addImg(Img img) throws Exception;

    /**
     * 修改关联id
     * @param releId 关联id
     * @param imgId 图片id
     * @return
     * @throws Exception
     */
    @Update("UPDATE pn_base.`img` SET releId=#{releId} WHERE imgId=#{imgId}")
    Integer updateReleId(@Param("releId") Integer releId,@Param("imgId") Integer imgId) throws Exception;

    /**
     * 查询最大主键
     * @return
     * @throws Exception
     */
    @Select("SELECT MAX(imgId) FROM pn_base.img;")
    Integer getMaxId() throws Exception;
}
